﻿
@{
    ViewData["Title"] = "Details";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="/Projects/Index">Projects</a></li>
        <li class="breadcrumb-item active" aria-current="page">Project Details</li>
    </ol>
</nav>

<div class="container">
    <div class="row">
        <div class="col">
            <a href="/Projects/Details?projectid=@ViewBag.Project.Id">@ViewBag.Project.Name</a>
        </div>
        <div class="col">
        </div>
        <div class="col">
            <a href="/Projects/Edit?projectid=@ViewBag.Project.Id">Edit</a>
            <a href="javascript:buildProject('@ViewBag.Project.Id')">Build</a>
            <a href="javascript:deleteProject('@ViewBag.Project.Id')">Delete</a>
        </div>
    </div>
</div>
<br />
<div class="container">
    @foreach (var item in ViewBag.Buildlogs)
    {
    <div class="row">
        <div class="col">
            <a href="/Projects/BuildLogDetails?buildlogid=@item.Id">@item.Id</a>
        </div>
        <div class="col">
            <span>@item.BuildState</span>
        </div>
        <div class="col">
            <span>@item.BuildTime</span>
        </div>
        <div class="col">
            <span>@item.BuildedTime</span>
        </div>
        <div class="col">
            <a href="javascript:deleteBuildLog('@item.Id')">Delete</a>
        </div>
    </div>
    }
</div>


@section Scripts{

    <script>
        function buildProject(projectid) {
            $.post("/Projects/BuildProject", { projectid: projectid }, function (res) {
                if (res.code == 1) {
                }
            });
        }
        function deleteProject(projectid) {
            $.post("/Projects/DeleteProject", { projectid: projectid }, function (res) {
                if (res.code == 1) {
                    location.href = '/Projects/Index';
                }
            });
        }

        function deleteBuildLog(buildlogid) {
            $.post("/Projects/DeleteBuildLog", { buildlogid: buildlogid }, function (res) {
                if (res.code == 1) {
                    location.reload();
                }
            });
        }


        setTimeout(function () {
            location.reload();
        }, 3000);

    </script>

}
